package fileutils

import (
	"os"
	"fmt"
	"gitee.com/DengAnbang/goutils/loge"
)

var (
	RootPath     = "./res/"
	ViewRootPath = RootPath + "view/"
	LogRootPath  = RootPath + "log/"
	FileRootPath = RootPath + "file/"

)

func init() {
	os.MkdirAll(FileRootPath, os.ModePerm)
	os.MkdirAll(LogRootPath, os.ModePerm)
	os.MkdirAll(ViewRootPath, os.ModePerm)
	loge.SetLogPath(LogRootPath)

}

/**
文件是否存在
 */
func PathExists(path string) (bool) {
	_, err := os.Stat(path)
	if err == nil {
		return true
	}
	return os.IsExist(err)
}

func Filename2Url(filename string, parentNode string) string {
	return fmt.Sprintf(`/app/file/%s/%s`, parentNode, filename)
}
